package com.ourtech.eam.resource.action;

import org.apache.log4j.Logger;

import com.ourtech.eam.action.BaseAction;
import com.ourtech.eam.resource.service.IEamResourceService;
import com.ourtech.eam.util.EamServiceException;
import com.ourtech.eam.util.StringUtil;

@SuppressWarnings("unchecked")
public class EamResourceAction<EamResource> extends BaseAction {

	private static final long serialVersionUID = 20090101901002L;

	private static final Logger log = Logger.getLogger(EamResourceAction.class);

	private IEamResourceService resourceService;
	
	public String listAllResource() {
		try {
			log.info("===EamResourceAction.listAllResource===");
			list = resourceService.listAll();
			return SUCCESS;
		} catch (EamServiceException ese) {
			log.error("EamResourceAction.listAllResource:", ese);
			return ERROR;
		} catch (Exception e) {
			return ERROR;
		}
	}

	public String deleteResource() {
		try {
			log.info("===EamResourceAction.deleteResource===idArray:" + idArrays);
			resourceService.delete(StringUtil.getArrayFromString(idArrays, ","));
			idArrays = null;
		} catch (EamServiceException ese) {
			log.error("EamResourceAction.listAllResource:", ese);
			ese.getErrorCode();
		} catch (Exception e) {
			log.error("EamResourceAction.listAllResource:", e);
		}
		return SUCCESS;
	}
	
	
	
	
	public IEamResourceService getResourceService() {
		return resourceService;
	}

	public void setResourceService(IEamResourceService resourceService) {
		this.resourceService = resourceService;
	}
}
